package com.academic_system.service.impl;

import com.academic_system.model.Party;
import com.academic_system.mapper.PartyDao;
import com.academic_system.service.PartyService;
import com.academic_system.util.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @description 党支部业务实现类
 * @project_name PartyImpl
 * @package com.academic_system.service.impl
 **/
@Service
//@Transactional(rollbackFor=Exception.class)
public class PartyImpl implements PartyService {
    @Autowired
    private PartyDao partyDao;

    /**
     * @param party_organization_num
     * @Description 根据党支部编号party_organization_num查询党支部信息
     * @methodName queryPartyByPartyOrganizationNum
     * @returnType Message
     **/
   // @Cacheable(value = "myCache", key = "'PartyService.queryPartyByPartyOrganizationNum'")
    @Override
    public Message queryPartyByPartyOrganizationNum(int party_organization_num) {
        System.out.println("*************************************************我是Party*************************************************");
        Party party = partyDao.queryPartyByPartyOrganizationNum(party_organization_num);
        if (party!=null){
            return Message.success().add("party",party);
        }
        return Message.fail().add("1101","查询失败");
    }

    /**
     * @Description 查询党支部名称
     * @methodName queryPartyName
     * @returnType List
     **/
    @Override
    public List<String> queryPartyName() {
        List<String> partyName=partyDao.queryPartyName();
        return partyName;
    }

    /**
     * @param party_organization_num
     * @Description 根据党支部编号party_organization_num查询党支部名称
     * @methodName queryPartyNameByPartyOrganizationNum
     * @returnType String
     **/
    @Override
    public String queryPartyNameByPartyOrganizationNum(int party_organization_num) {
        String partyName=partyDao.queryPartyNameByPartyOrganizationNum(party_organization_num);
        return partyName;
    }
}

